log close
log using isq-pta&labor, replace

***********************
**Tables**
***********************

use isq-pta&labor-data, clear

//Table 1

quietly probit pta lag_pressure_cont ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock  lag_num _t0 t2 t3 if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("Table 1") ctitle(" ")replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)


//Table 2

quietly oprobit labor_prov lag_pressure_cont ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("Table 2") ctitle(" ")replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

//Table 3

quietly probit pta lag_pressure_cont inter1 lag_gap_lp ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock  lag_num _t0 t2 t3 if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("Table 2") ctitle(" ")append noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

****************************
**Figures**
****************************

//Figure 1
use isq-pta&labor-data, clear

gen group1=lag_pressure_cont if pta==1
gen group2=lag_pressure_cont if pta==0

twoway (hist group1, percent col(gs8)width(0.1) legend(label(1 "pta"))) (hist group2, percent fcol(none)col(gs13) width(0.1)legend(label(2 "no pta") )), ///
scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) ///
yscale(noline) plotregion(lcolor(black)) ///
ylabel(5(10)50, nogrid)xlabel(0(1)2) xtitle(Policy pressure) ytitle(Percentage of dyads) legend(ring(0)position(10)symxsize(3)symysize(0.2)col(1)) ///
title("Figure 1: Policy Pressure and PTA Formation", size(small) margin(b=5)) 

	graph export lr&pta_f1.tif, replace width(4000)

//Figure 2
use isq-pta&labor-data, clear

quietly probit pta lag_pressure_cont ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num _t0 t2 t3 if _d!=., robust cluster(dyad)

quietly margins, dydx(*)

estimates store margins


coefplot margins, drop(_cons _t0 t2 t3) xline(0, lwidth(vvthin)) cismooth grid(none)  ///
msymbol(o) mfcolor(white) levels(90 95 99)ciopts(lwidth(*0.5)lcolor(gs13))  ///
scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) ///
yscale(noline) plotregion(lcolor(black)) xsize(12) ysize(8) title("", size(ms)) ylabel(,labsize(small)) xtitle(Marginal effects) ///
title("Figure 2: Marginal Effects of Independent Variables on the Probability of Signing PTAs", size(small)margin(b=5)) ///
note("Note: Figure 2 is created based on the results of Model 1. The hollow circle denotes" /// 
"the marginal effect of each independent variable. The shortest darker line indicates the" ///
"90% confidence interval, while the longest lighter line indicates the 99% confidence interval."   ///
, size(small))
	
	graph export lr&pta_f2.tif, replace width(3000)


//Figure 3
use isq-pta&labor-data, clear

quietly probit pta lag_pressure_cont ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num _t0 t2 t3 if _d!=., robust cluster(dyad)

predict yhat, p
gen yhat2=yhat if lag_pressure_cont==2
gen yhat1=yhat if lag_pressure_cont==1
gen yhat0=yhat if lag_pressure_cont==0

su yhat1, meanonly
su yhat0, meanonly

twoway (hist yhat2, col(gs6)width(0.00003)legend(label(1 "common pressure") )) (hist yhat1, fcol(none) lcol(gs10) lpattern() width(0.01)legend(label(2 "partial pressure") )) ///
(hist yhat0, fcol(none) lcol(gs14) lpattern() width(0.01)legend(label(3 "no pressure") )), ///
scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) ///
yscale(noline) plotregion(lcolor(black)) ///
ylabel(10(30)100, nogrid) xtitle(Predicted probabilities of signing PTAs) ///
 legend(ring(0)position(2)symxsize(3)symysize(0.2)col(1)) xsize(10) ysize(8) ///
 title("Figure 3: Predicted Probabilities of Signing PTAs across Three Groups of Dyads", size(small) margin(b=5))
 
 	graph export lr&pta_f3.tif, replace width(3000)

//Figure 4

clear 
set obs 50
gen lag_pressure_cont=0
gen ltrade=69
gen lfdi=2
gen lgdp_ln=23
gen lgdppc_ln=8 
gen lgdp_growth=2
gen lalliance=0
gen ldemocracy=2
gen distance=8
gen lwto=1
gen lmultiround=1
gen ltrdispute=0
gen colony=0
gen language=0 
gen religion=0
gen dif_ab=0.6 
gen lag_shock=0 
gen lag_num=1

save pta_lr_oprobit_sim_0, replace

///
clear 
set obs 50
gen lag_pressure_cont=2
gen ltrade=77
gen lfdi=2
gen lgdp_ln=23
gen lgdppc_ln=9 
gen lgdp_growth=3
gen lalliance=0
gen ldemocracy=7
gen distance=8
gen lwto=1
gen lmultiround=1
gen ltrdispute=0
gen colony=0
gen language=0 
gen religion=0
gen dif_ab=0.2 
gen lag_shock=0 
gen lag_num=0

save pta_lr_oprobit_sim_1, replace

////
use isq-pta&labor-data, clear

quietly oprobit labor_prov lag_pressure_cont ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num if _d!=., robust cluster(c)

////
use pta_lr_oprobit_sim_0, clear

predict pr1 pr2 pr3 pr4

rename pr1 pr1_0
rename pr2 pr2_0
rename pr3 pr3_0
rename pr4 pr4_0

gen id=_n
keep pr* id
save pta_lr_oprobit_sim_0_result, replace

////
use isq-pta&labor-data, clear

quietly oprobit labor_prov lag_pressure_cont ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num if _d!=., robust cluster(c)

////
use pta_lr_oprobit_sim_1, clear

predict pr1 pr2 pr3 pr4

gen id=_n
merge 1:1 id using "pta_lr_oprobit_sim_0_result"

//
grstyle init
grstyle set plain, nogrid noextend

twoway (scatter pr1_0 pr1  lag_pressure_cont, mcolor(gs10 gs6) msymbol(Sh T)lwidth(medthick)), ///
legend(off) xlabel(, nolabels) xtitle("") ytitle(Pr(no labor provision))
graph save pta_lr_op0.gph, replace

twoway (scatter pr2_0 pr2  lag_pressure_cont, mcolor(gs10 gs6) msymbol(Sh T) lwidth(medthick)), ///
legend(off) xlabel(, nolabels) xtitle("") ytitle(Pr(weak labor provision))
graph save pta_lr_op1.gph, replace

twoway (scatter pr3_0 pr3  lag_pressure_cont, mcolor(gs10 gs6) msymbol(Sh T) lwidth(medthick)), ///
legend(off) xlabel(, nolabels) xtitle("") ytitle(Pr(medium labor provision))
graph save pta_lr_op2.gph, replace

twoway (scatter pr4_0 pr4  lag_pressure_cont, mcolor(gs10 gs6) msymbol(Sh T) lwidth(medthick)), ///
legend(cols(1) order(1 "policy pressure=0" 2 "policy pressure=2") size(small) ring(0) position(3) bmargin(large)) ///
xtitle("") xlabel(, nolabels) ytitle(Pr(strong labor provision))
graph save pta_lr_op3.gph, replace

graph combine pta_lr_op0.gph pta_lr_op1.gph pta_lr_op2.gph pta_lr_op3.gph, xsize(4) ysize(6) ///
title("Figure 4: Predicted Probabilities for Different Levels of Labor Provisions in PTAs",size(small) margin(b=5))
	graph export lr&pta_f4.tif, replace width(3000)

	
//Figure 5
use isq-pta&labor-data, clear
quietly probit pta lag_pressure_cont inter1 lag_gap_lp ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock  lag_num _t0 t2 t3 if _d!=., robust cluster(c)

su lag_pressure_ab lag_gap_lp ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num _t0 t2 t3 if e(sample)

tab lwto if e(sample)
tab lmultiround if e(sample)
tab ltrdispute if e(sample)
tab colony if e(sample)
tab language if e(sample)
tab religion if e(sample)

///simulation 
preserve
drawnorm SN_b1-SN_b24, n(100000) means(e(b)) cov(e(V)) clear
postutil clear
postfile mypost prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 diff_hat diff_lo diff_hi using sim, replace
            noisily display "start" 
						
local a=-2
while `a' <=4 { 
{
scalar h_lag_pressure_cont=0
scalar h_ltrade=60.5
scalar h_lfdi=1.9
scalar h_lgdp_ln=22.8
scalar h_lgdppc_ln=7
scalar h_lgdp_growth=1.8
scalar h_lalliance=80
scalar h_ldemocracy= 0
scalar h_distance=8.8
scalar h_lwto=1
scalar h_lmultiround=1
scalar h_ltrdispute=0
scalar h_colony=0
scalar h_language=0
scalar h_religion=0
scalar h_dif_ab=0.2
scalar h_lag_shock=0.2
scalar h_lag_num=0.2
scalar h__t0=10
scalar h_t2=119
scalar h_t3=1665
scalar h_constant=1

generate x_betahat0  = SN_b1* h_lag_pressure_cont + SN_b2*`a' + SN_b3*h_lag_pressure_cont*`a' + SN_b4*h_ltrade + SN_b5*h_lfdi ///
                            + SN_b6*h_lgdp_ln + SN_b7*h_lgdppc_ln + SN_b8*h_lgdp_growth + SN_b9*h_lalliance ///
                            + SN_b10*h_ldemocracy + SN_b11*h_distance + SN_b12*h_lwto + SN_b13*h_lmultiround ///
							+ SN_b14*h_ltrdispute + SN_b15*h_colony + SN_b16*h_language + SN_b17*h_religion ///
                            + SN_b18*h_dif_ab + SN_b19*h_lag_shock + SN_b20*h_lag_num + SN_b21*h__t0 + SN_b22*h_t2 + SN_b23*h_t3 + SN_b24*h_constant ///
						   
							
generate x_betahat1  = SN_b1* (h_lag_pressure_cont+2) + SN_b2*`a' + SN_b3*(h_lag_pressure_cont+1)*`a' + SN_b4*h_ltrade + SN_b5*h_lfdi ///
                            + SN_b6*h_lgdp_ln + SN_b7*h_lgdppc_ln + SN_b8*h_lgdp_growth + SN_b9*h_lalliance ///
                            + SN_b10*h_ldemocracy + SN_b11*h_distance + SN_b12*h_lwto + SN_b13*h_lmultiround ///
							+ SN_b14*h_ltrdispute + SN_b15*h_colony + SN_b16*h_language + SN_b17*h_religion ///
                            + SN_b18*h_dif_ab + SN_b19*h_lag_shock + SN_b20*h_lag_num + SN_b21*h__t0 + SN_b22*h_t2 + SN_b23*h_t3 + SN_b24*h_constant 
         
gen prob0=1/(1+exp(-x_betahat0))
gen prob1=1/(1+exp(-x_betahat1))
gen diff=prob1-prob0
egen probhat0=mean(prob0)
egen probhat1=mean(prob1)
egen diffhat=mean(diff)
tempname prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 diff_hat diff_lo diff_hi
_pctile prob0, p(10,90)
scalar `lo0' = r(r1)
scalar `hi0' = r(r2)  
_pctile prob1, p(10,90)
scalar `lo1'= r(r1)
scalar `hi1'= r(r2)   
_pctile diff, p(10,90)
scalar `diff_lo'= r(r1)
scalar `diff_hi'= r(r2)  
scalar `prob_hat0'=probhat0
scalar `prob_hat1'=probhat1
scalar `diff_hat'=diffhat    
post mypost (`prob_hat0') (`lo0') (`hi0') (`prob_hat1') (`lo1') (`hi1') (`diff_hat') (`diff_lo') (`diff_hi')
}      
drop x_betahat0 x_betahat1 prob0 prob1 diff probhat0 probhat1 diffhat
local a=`a'+ 1
display "." _c
      } 
	
display ""
postclose mypost  

///
use sim, clear
range MV -2 4 
gen yline=0
	
	twoway  (scatter diff_hat MV, msymbol(Oh) col(gs8)) (rcap diff_lo diff_hi MV, mstyle(p12)col(gs13))(line diff_hat MV), ///
	xlabel(-2(1)4, nogrid labsize(2.5)) ylabel(0 (0.0001)0.0002, axis(1) nogrid labsize(2.5)) ///
 yscale(noline)  xscale(noline)  yline(0, lcolor(black) lstyle(min)) ///
   xtitle("Domestic violation of labor rights", size(3)) ytitle("Marginal effect of common policy pressure on PTA formation", axis(1)size(2.5)height()) ///
   xsca(titlegap(4)) ysca(axis(1)titlegap(4)) ///
 scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white)) ///
 legend (on order(1 2) col(1) label(1 "Pr. of signing PTAs") label(2 "90% confidence interval") symxsize(5) size(vsmall)) ///
 title("Figure 5: Marginal Effect of Policy Pressure to Reduce Legal Labor Protection on the" ///
 "Probability of Signing PTAs Conditional on the Ability to Repress Labor in Practice",size(small) linegap(2) margin(b=12))
	
	graph export lr&pta_f5.tif, replace width(3000)
	
	
*********************************
**Figures in Appendix**
*********************************

//histograms 

use isq-pta&labor-data, clear

set more off 

hist pta, percent ylab(, nogrid) kdensity kdenopts(lc(red))  col(gs13)width(0.01) plotregion(lcolor(black)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) 
graph save h1.gph, replace

hist lag_pressure_cont, percent ylab(, nogrid) kdensity kdenopts(lc(red))  col(gs13)width(0.01) plotregion(lcolor(black)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) 
graph save h2.gph, replace

hist ltrade, percent ylab(, nogrid) kdensity kdenopts(lc(red))  col(gs13)width(0.01) plotregion(lcolor(black)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) 
graph save h3.gph, replace

hist lfdi, percent ylab(, nogrid) kdensity kdenopts(lc(red))  col(gs13)width(0.01) plotregion(lcolor(black)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) 
graph save h4.gph, replace

hist lgdp_ln, percent ylab(, nogrid) kdensity kdenopts(lc(red))  col(gs13)width(0.01) plotregion(lcolor(black)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) 
graph save h5.gph, replace

hist lgdppc_ln, percent ylab(, nogrid) kdensity kdenopts(lc(red))  col(gs13)width(0.01) plotregion(lcolor(black)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) 
graph save h6.gph, replace
 
hist lgdp_growth, percent ylab(, nogrid) kdensity kdenopts(lc(red))  col(gs13)width(0.01) plotregion(lcolor(black)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) 
graph save h7.gph, replace

hist lalliance, percent ylab(, nogrid) kdensity kdenopts(lc(red))  col(gs13)width(0.01) plotregion(lcolor(black)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) 
graph save h8.gph, replace
 
hist ldemocracy, percent ylab(, nogrid) kdensity kdenopts(lc(red))  col(gs13)width(0.01) plotregion(lcolor(black)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) 
graph save h9.gph, replace
 
hist distance, percent ylab(, nogrid) kdensity kdenopts(lc(red))  col(gs13)width(0.01) plotregion(lcolor(black)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) 
graph save h10.gph, replace
 
hist lwto,percent ylab(, nogrid) kdensity kdenopts(lc(red))  col(gs13)width(0.01) plotregion(lcolor(black)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) 
graph save h11.gph, replace
 
hist lmultiround,percent ylab(, nogrid) kdensity kdenopts(lc(red))  col(gs13)width(0.01) plotregion(lcolor(black)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) 
graph save h12.gph, replace

hist ltrdispute, percent ylab(, nogrid) kdensity kdenopts(lc(red))  col(gs13)width(0.01) plotregion(lcolor(black)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) 
graph save h13.gph, replace
 
hist colony, percent ylab(, nogrid) kdensity kdenopts(lc(red))  col(gs13)width(0.01) plotregion(lcolor(black)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) 
graph save h14.gph, replace

hist language,percent ylab(, nogrid) kdensity kdenopts(lc(red))  col(gs13)width(0.01) plotregion(lcolor(black)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) 
graph save h15.gph, replace
 
hist religion, percent ylab(, nogrid) kdensity kdenopts(lc(red))  col(gs13)width(0.01) plotregion(lcolor(black)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) 
graph save h16.gph, replace

hist dif_ab, percent ylab(, nogrid) kdensity kdenopts(lc(red))  col(gs13)width(0.01) plotregion(lcolor(black)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) 
graph save h17.gph, replace

hist lag_shock, percent ylab(, nogrid) kdensity kdenopts(lc(red))  col(gs13)width(0.01) plotregion(lcolor(black)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) 
graph save h18.gph, replace

hist lag_num, percent ylab(, nogrid) kdensity kdenopts(lc(red))  col(gs13)width(0.01) plotregion(lcolor(black)) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white)) 
graph save h19.gph, replace

graph combine h1.gph h2.gph h3.gph h4.gph h5.gph h6.gph h7.gph h8.gph h9.gph h10.gph h11.gph h12.gph h13.gph h14.gph h15.gph h16.gph h17.gph h18.gph h19.gph, col(4) scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white))

graph export fa1.tif, replace width(2500)

	//correlation
use isq-pta&labor-data, clear

set more off

set scheme s1color

corrtable  pta lag_pressure_cont ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance ///
lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num, ///
flag1(abs(r(rho)) > 0.8) howflag1(mlabsize(*7)) flag2(inrange(abs(r(rho)), 0.6, 0.8)) howflag2(mlabsize(*6)) half ///
graphregion(fcolor(white) ilcolor(white) lcolor(white) lp(blank) ilp(white))

graph export fa2.tif, replace width(2500)

*********************************
**Robustness Checks**
*********************************

//1. considering investment discrimination

use isq-pta&labor-data, clear

sort dyad year
set more off

quietly probit pta lag_pressure_cont fdi_exp_iv_spatial_ln ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num  _t0 t2 t3 if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

///
quietly oprobit labor_prov lag_pressure_cont fdi_exp_iv_spatial_ln ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

///

quietly probit pta lag_pressure_cont inter1 lag_gap_lp fdi_exp_iv_spatial_ln ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num _t0 t2 t3 if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)


//2. various lags
use isq-pta&labor-data, clear
set more off

sort dyad year
bys dyad: gen lag2_pressure_cont=lag_pressure_cont[_n-1]
bys dyad: gen lag3_pressure_cont=lag_pressure_cont[_n-2]
bys dyad: gen lag4_pressure_cont=lag_pressure_cont[_n-3]
bys dyad: gen lag5_pressure_cont=lag_pressure_cont[_n-4]

quietly probit pta lag2_pressure_cont ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num  _t0 t2 t3 if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3)  e(ll chi2) title() ctitle("") replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

quietly probit pta lag3_pressure_cont ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num  _t0 t2 t3 if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3)  e(ll chi2) title("") ctitle("") append noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3) 
//
quietly probit pta lag4_pressure_cont ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num  _t0 t2 t3 if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3)  e(ll chi2) title("") ctitle("") append noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

quietly probit pta lag5_pressure_cont ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num  _t0 t2 t3 if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3)  e(ll chi2) title("") ctitle("") append noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3) sortvar(lag2_pressure_cont lag3_pressure_cont lag4_pressure_cont lag5_pressure_cont)

///
// 2 yr lag
bys dyad: gen lag2_gap_lp=gap_lp_small[_n-2]
gen inter3=lag2_gap_lp*lag2_pressure_cont

//3 yr
sort dyad year
bys dyad: gen lag3_gap_lp=gap_lp_small[_n-3]
gen inter4=lag3_gap_lp*lag3_pressure_cont

//4 yr
sort dyad year
bys dyad: gen lag4_gap_lp=gap_lp_small[_n-4]
gen inter5=lag4_gap_lp*lag4_pressure_cont

//5 yr
sort dyad year
bys dyad: gen lag5_gap_lp=gap_lp_small[_n-5]
gen inter6=lag5_gap_lp*lag5_pressure_cont

//
quietly probit pta lag2_pressure_cont inter3 lag2_gap_lp ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num _t0 t2 t3 if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

quietly probit pta lag3_pressure_cont inter4 lag3_gap_lp ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num _t0 t2 t3 if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")append noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

quietly probit pta lag4_pressure_cont inter5 lag4_gap_lp ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num _t0 t2 t3 if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")append noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

quietly probit pta lag5_pressure_cont inter6 lag5_gap_lp ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num _t0 t2 t3 if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("Table A.4") ctitle(" ")append noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3) ///
sortvar(lag2_pressure_cont inter3 lag3_pressure_cont inter4 lag4_pressure_cont inter5 lag5_pressure_cont inter6 ///
ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num ///
lag2_gap_lp lag3_gap_lp lag4_gap_lp lag5_gap_lp)


//3. continuous policy pressure
use isq-pta&labor-data, replace

quietly probit pta lag_pressure_small ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num _t0 t2 t3 if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3)  e(ll chi2) title("") ///
addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3) ///
replace

///
quietly oprobit labor_prov lag_pressure_small ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num if _d!=., robust cluster(c)

outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

///
quietly probit pta lag_pressure_small inter2 lag_gap_lp ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num _t0 t2 t3 if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)


//4. FDI-based
use isq-pta&labor-data, clear

quietly probit pta lag_pressure_cont_fdi ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num _t0 t2 t3 if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

///
quietly oprobit labor_prov lag_pressure_cont_fdi ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("Table 2") ctitle(" ")replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

///
quietly probit pta lag_pressure_cont_fdi inter2_fdi lag_gap_lp ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num _t0 t2 t3 if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)


//5.considering resources rent 
use isq-pta&labor-data, clear

quietly probit pta lag_pressure_cont  ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num resources_small  _t0 t2 t3 if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

///
quietly oprobit labor_prov lag_pressure_ab ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num resources_small if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

/// interaction model
quietly probit pta lag_pressure_cont inter1 lag_gap_lp ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num resources_small _t0 t2 t3 if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)


//6.fixed effects
use isq-pta&labor-data, replace

set more off

quietly probit pta lag_pressure_cont ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num _t0 t2 t3 i.year if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

quietly probit pta lag_pressure_cont ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num _t0 t2 t3  i.region_labelwa_c i.region_labelwb_c if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")append noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

quietly probit pta lag_pressure_cont ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num _t0 t2 t3 i.year  i.region_labelwa_c i.region_labelwb_c if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")append noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

///
quietly oprobit  labor_prov lag_pressure_ab ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock i.region_labelwa_c i.region_labelwb_c if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

///
quietly probit pta lag_pressure_cont inter1 lag_gap_lp ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num _t0 t2 t3 i.year if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

quietly probit pta lag_pressure_cont inter1 lag_gap_lp ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num _t0 t2 t3  i.region_labelwa_c i.region_labelwb_c if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") append noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

quietly probit pta lag_pressure_cont inter1 lag_gap_lp ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num _t0 t2 t3 i.year  i.region_labelwa_c i.region_labelwb_c if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")append noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

//7. survival model
use isq-pta&labor-data, clear

stset endtime, id(dyad) time0(starttime) origin(time starttime) failure(pta=1) exit(pta=1) 

quietly stcox lag_pressure_cont ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num  if _d!=., robust cluster(c) nohr
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")replace noni addtext(Cubic polynomials, yes) 

//
quietly stcox lag_pressure_cont inter1 lag_gap_lp ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num if _d!=., robust cluster(dyad) nohr
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")replace noni addtext(Cubic polynomials, yes) 

//8. excluding the us ptas
use isq-pta&labor-data, clear

drop if cowcode==2
drop if ccodecow==2

quietly oprobit labor_prov lag_pressure_ab ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock lag_num if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("Table 2") ctitle(" ")replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

//9. replacing labor law difference with minimum value of gap in facb law within a dyad
use isq-pta&labor-data, clear

quietly oprobit labor_prov lag_pressure_cont ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion lag_facb_l lag_shock lag_num if _d!=., robust cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

//10. selection for labor provision
use isq-pta&labor-data, clear

///manually calculate inverse mills ratio
quietly probit pta lag_pressure_cont ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock  lag_num _t0 t2 t3, vce(cluster c) 

capture drop hat
capture drop invmills
predict hat if e(sample), xb
gen invmills=exp(-.5*hat^2)/(sqrt(2*_pi)*normprob(hat))

replace labor_prov=0 if labor_prov==.

quietly oprobit labor_prov lag_pressure_cont ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock invmills, cluster(c)
outreg2 using pta_lr, label word dec(3) e(ll chi2) title("") ctitle(" ")replace noni addtext(Cubic polynomials, yes) drop(_t0 t1 t2 t3)

//11.interflex
use isq-pta&labor-data, clear
interflex pta lag_pressure_cont lag_gap_lp inter1 ltrade lfdi lgdp_ln lgdppc_ln lgdp_growth lalliance ldemocracy distance lwto lmultiround ltrdispute colony language religion dif_ab lag_shock  lag_num _t0 t2 t3 if _d!=., type(linear)cluster(c)
graph export fa3.tif, width(2500)replace
